<template>
	<view class="expert-page">
		<u-navbar :autoBack="true" title="成为达人" :placeholder="true" bgColor="rgba(255,255,255,0)"></u-navbar>
		<view class="content">
			<view class="item" @click="goupinfo(1)"></view>
			<view v-if="info!=null">
				<view class="release" @click="goupinfo(2)" v-if="info.approve_status == 1"></view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions
	} from 'vuex';
	export default {
		data(){
			return {
				info:{}
			}
		},
		onShow() {
			this.getfriendinfo()
		},
		computed: {
			...mapState(['isRealName']),
		},
		methods:{
			...mapActions(['checkRealName']),
			getfriendinfo() {
				this.$Request({
					method: 'POST',
					url: '/api/friend/getMyInfo',
					data: {},
					ismsg: false,
				}).then(res => {
					console.log(res)
					if(res.code == 1){
						this.info = res.data
					}else{
						this.info = null
					}
				})
			},
			async goupinfo(type){
				try {
					await this.checkRealName();
					if (this.isRealName) {
						if(type == 1){
							this.$navTo.togo('/pages/my/expert/accept/index')
						}else{
							// 我的发布
							this.$navTo.togo('/pages/my/expert/myaccept/index')
						}
					} else {
						uni.showToast({
							title: '请先实名！',
							icon: 'none'
						})
						setTimeout(() => {
							this.$navTo.togo('/pages/my/real/index')
						}, 1000)
					}
				} catch (error) {
					console.error(error);
				}
			}
		}
	}
</script>

<style>
	page {
		background-color: #F7F8FC;
	}
</style>
<style lang="scss" scoped>
	.expert-page {
		min-height: 100vh;
		background-image: url('https://m.lqvvvv.com/assets/static/index/nav-bg.png');
		background-repeat: no-repeat;
		background-size: 100% 800rpx;
		.content {
			padding: 40rpx;
			.item {
				height: 276rpx;
				background-image: url('https://m.lqvvvv.com/assets/static/my/expert-bg1.png');
				background-repeat: no-repeat;
				background-size: 100% 100%;
				margin-top: 40rpx;
			}
			.release {
				height: 276rpx;
				background-image: url('https://m.lqvvvv.com/assets/static/my/expert-bg2.png');
				background-repeat: no-repeat;
				background-size: 100% 100%;
				margin-top: 40rpx;
			}
		}
	}
</style>